#include <iostream>
#include <string>
using namespace std;
int lengthOfLongestSubstring(string s)
{
    int hash[128];
    int len = 0;
    for (int left = 0, right = 0; right < s.size(); right++)
    {
        hash[s[right]]++;
        while (hash[s[right]] == 2)
        {
            hash[s[left]]--;
            left++;
        }
        len = max(len, right - left + 1);
    }
    return len;
}